//---------------------------------------------------------------------------
#ifndef uCalcCommonH
#define uCalcCommonH
//---------------------------------------------------------------------------
#include <utilcls.h>
#include "eic.h"
#include "outils.h"
//---------------------------------------------------------------------------
#define COLOR_TRANSPARENT ( long)0xFFFFFFFF
//---------------------------------------------------------------------------
enum line_style  { ls_none=0, ls_continuous };
enum line_weight { lw_thin=0, lw_thick };
enum text_align  { ta_left=0, ta_right, ta_center, ta_top, ta_bottom };
//---------------------------------------------------------------------------
typedef struct {
  line_style  eStyle;
  line_weight eWeight;
} CBorder;
//---------------------------------------------------------------------------
typedef struct {
  CBorder top;
  CBorder right;
  CBorder bottom;
  CBorder left;
  CBorder inside_vertical;
  CBorder inside_horizontal;
} CBorders;
//---------------------------------------------------------------------------
typedef struct {
  text_align eHorizontal;
  text_align eVertical;
} CTextAlign;
//---------------------------------------------------------------------------
extern PACKAGE_OUTILS CBorder BORDER_THIN, BORDER_THICK, BORDER_NONE;
//---------------------------------------------------------------------------
class CCalc;
class COLEObj
{
  protected:
    Variant m_vOleObj;
    CCalc  *m_pCalc;    // Utiliser dans OpenOffice

  public:
    __fastcall COLEObj( void);

    __property Variant OLEObject = { read=m_vOleObj };
};
//---------------------------------------------------------------------------
class CCalcStyle : virtual public COLEObj
{
  protected:
    virtual long        __fastcall GetBackgroundColor( void) = 0;
    virtual void        __fastcall SetBackgroundColor( long lColor) = 0;
    virtual CBorders    __fastcall GetBorders( void) = 0;
    virtual void        __fastcall SetBorders( const CBorders &eBorders) = 0;
    virtual CTextAlign  __fastcall GetTextAlign( void) = 0;
    virtual void        __fastcall SetTextAlign( const CTextAlign &eAlign) = 0;
    virtual TFontStyles __fastcall GetFontStyle( void) = 0;
    virtual void        __fastcall SetFontStyle( const TFontStyles &eStyle) = 0;
    virtual bool        __fastcall GetLocked( void) = 0;
    virtual void        __fastcall SetLocked( bool bLocked) = 0;

  public:
    __fastcall CCalcStyle( void) : COLEObj() {};

    __property long        BackgroundColor = { read=GetBackgroundColor, write=SetBackgroundColor };
    __property CBorders    Borders         = { read=GetBorders        , write=SetBorders         };
    __property CTextAlign  TextAlign       = { read=GetTextAlign      , write=SetTextAlign       };
    __property TFontStyles FontStyle       = { read=GetFontStyle      , write=SetFontStyle       };
    __property bool        Locked          = { read=GetLocked         , write=SetLocked          };
};
//---------------------------------------------------------------------------
class CCalcCell : virtual public COLEObj, virtual public CCalcStyle
{
  protected:
    virtual AnsiString __fastcall GetText( void) = 0;
    virtual void       __fastcall SetText( const AnsiString &strText) = 0;
    virtual Currency   __fastcall GetMoney( void) = 0;
    virtual void       __fastcall SetMoney( const Currency &curValue) = 0;
    virtual TDateTime  __fastcall GetDate( void) = 0;
    virtual void       __fastcall SetDate( const TDateTime &dtValue) = 0;

  public:
    __fastcall CCalcCell( void);

    __property TDateTime  Date  = { read=GetDate , write=SetDate  };
    __property AnsiString Text  = { read=GetText , write=SetText  };
    __property Currency   Money = { read=GetMoney, write=SetMoney };
};
//---------------------------------------------------------------------------
class CCalcCells : public COLEObj
{
  protected:
    virtual CCalcCell *__fastcall GetItem( int x, int y) = 0;

  public:
    __fastcall CCalcCells( void);

    __property CCalcCell *Item[int x][int y] = { read=GetItem };
};
//---------------------------------------------------------------------------
class CCalcRange : virtual public COLEObj, virtual public CCalcStyle
{
  public:
    __fastcall CCalcRange( void);
};
//---------------------------------------------------------------------------
class CCalcColumn : public COLEObj
{
  protected:
    virtual int  __fastcall GetWidth( void) = 0;
    virtual void __fastcall SetWidth( int nWidth) = 0;

  public:
    __fastcall CCalcColumn( void);

    __property int Width = { read=GetWidth, write=SetWidth };
};
//---------------------------------------------------------------------------
class CCalcColumns : public COLEObj
{
  protected:
    virtual int          __fastcall GetCount( void) = 0;
    virtual CCalcColumn *__fastcall GetItem( int c) = 0;

  public:
    __fastcall CCalcColumns( void);

    __property int          Count       = { read=GetCount };
    __property CCalcColumn *Item[int c] = { read=GetItem  };
};
//---------------------------------------------------------------------------
class CCalcWorksheet : public COLEObj
{
  protected:
    virtual CCalcCells *__fastcall GetCells( void) = 0;
    virtual CCalcColumns *__fastcall GetColumns( void) = 0;
    virtual AnsiString __fastcall GetName( void) = 0;

    virtual void __fastcall SetName( const AnsiString &strName) = 0;

  public:
    __fastcall CCalcWorksheet( void);

    virtual CCalcRange* __fastcall GetRange( int x1, int y1, int x2, int y2) = 0;
    virtual void        __fastcall Protect( const AnsiString &strPassword) = 0;

    __property CCalcCells   *Cells   = { read=GetCells   };
    __property CCalcColumns *Columns = { read=GetColumns };
    __property AnsiString    Name    = { read=GetName, write=SetName };
};
//---------------------------------------------------------------------------
class CCalcWorksheets : public COLEObj
{
  protected:
    virtual CCalcWorksheet *__fastcall GetItem( int nIndex) = 0;
    virtual int             __fastcall GetCount( void) = 0;

  public:
            __fastcall  CCalcWorksheets( void);
    virtual __fastcall ~CCalcWorksheets( void);

    virtual void __fastcall Add( void) = 0;

    __property int             Count            = { read=GetCount };
    __property CCalcWorksheet *Item[int nIndex] = { read=GetItem  };
};
//---------------------------------------------------------------------------
class CCalcWorkbook : public COLEObj
{
  protected:
    virtual CCalcWorksheets *__fastcall GetWorksheets( void) = 0;

  public:
            __fastcall  CCalcWorkbook( void);
    virtual __fastcall ~CCalcWorkbook( void);

    virtual void __fastcall Create( void) = 0;
    virtual void __fastcall Open( const AnsiString &strFilename) = 0;
    virtual void __fastcall SaveAs( const AnsiString &strFilename) = 0;

    __property CCalcWorksheets *Worksheets = { read=GetWorksheets };
};
//---------------------------------------------------------------------------
class PACKAGE_OUTILS CCalc : public COLEObj
{
  protected:
    virtual bool           __fastcall GetVisible( void) = 0;
    virtual void           __fastcall SetVisible( bool bVisible) = 0;
    virtual CCalcWorkbook *__fastcall GetWorkbook( void) = 0;

  public:
            __fastcall  CCalc( void);
    virtual __fastcall ~CCalc( void);

    __property bool           Visible  = { read=GetVisible, write=SetVisible };
    __property CCalcWorkbook *Workbook = { read=GetWorkbook };

    virtual void __fastcall Init( void);
    virtual void __fastcall Terminate( void);
};
//---------------------------------------------------------------------------
//#include <dstring.h>
#endif
